package com.plian.system.listener;

import com.plian.system.cache.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @description: 项目启动结束时运行
 * @author: gangan
 * @create: 2021-08-25 16:25
 */
@Slf4j
@Component
public class ApplicationStartFinishListener implements ApplicationListener<ApplicationStartedEvent> {

    /**
     * 缓存初始化flag
     */
    @Value("${cache.init-flag}")
    private boolean initFlag;

    @Override
    public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {
        if (initFlag){
            UserCache.init();
            OrgCache.init();
            DictCache.init();
            DeptCache.init();
            StaffCache.init();
            PropertyCache.init();
            OfficeCache.init();
        }
    }
}
